window.onload = function(){
    var app = new Vue({
        el:'#app',
        data:{
            singer:'五月天',
            musicList:[],
            musicUrl:'',
            musicCover: '',
            hotComments:[],
            isPlaying: false,
            isShow: false,
            mvUrl: ''
        },
        methods:{
            searchMusic:function(){
                var that = this;
                // 歌手的歌曲列表获取
                axios.get('https://autumnfish.cn/search?keywords='
                + this.singer).then(function(response){
                    // console.log(response);
                    that.musicList = response.data.result.songs;
                },function(err){
                    console.log(err);
                })
            },
            // 播放音乐
            playMusic:function(musicId){
                var that = this;
                // 歌曲链接获取
                axios.get('https://autumnfish.cn/song/url?id='
                +musicId).then(function(response){
                    // console.log(response.data.data[0].url)
                    that.musicUrl = response.data.data[0].url
                },function(err){
                    console.log(err);
                })
                // 歌曲详情获取
                axios.get('https://autumnfish.cn/song/detail?ids='
                +musicId).then(function(response){
                    // console.log(response.data.songs[0].al.picUrl)
                    that.musicCover = response.data.songs[0].al.picUrl;
                },function(err){
                    console.log(err);
                })
                // 歌曲评论获取
                axios.get('https://autumnfish.cn/comment/hot?type=0&id=' 
                + musicId).then(function(response){
                    // console.log(response.data.hotComments);
                    that.hotComments = response.data.hotComments;
                },function(err){
                    console.log(err);
                })
            },
            play(){
                this.isPlaying = true;
            },
            pause(){
                this.isPlaying = false;
            },
            playMv(mvid){
                var that = this;
                axios.get('https://autumnfish.cn/mv/url?id='
                +mvid).then(function(response){
                    // console.log(response.data.data.url)
                    that.isShow = true;
                    that.mvUrl = response.data.data.url;
                },function(err){
                    console.log(err);
                })
            },
            hide(){
                this.isShow = false;
            }
        }
    })
}